package com.feinno.urcs.group.siptask;

import com.feinno.rpc.channel.RpcFuture;
import com.feinno.rpc.client.RpcMethodStub;
import com.feinno.urcs.group.siptask.task.GroupSmsArgs;
import com.feinno.urcs.group.siptask.task.GroupTaskEvents;
import com.feinno.urcs.sms.SmsSenderService;
import org.helium.framework.annotations.FieldSetter;
import org.helium.framework.annotations.ServiceSetter;
import org.helium.framework.annotations.TaskImplementation;
import org.helium.framework.rpc.LegacyRpcClient;
import org.helium.framework.task.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by honghao on 8/18/15.
 */
@TaskImplementation(event = GroupTaskEvents.GROUP_SMS)
public class GroupSmsTask implements Task<GroupSmsArgs> {

	private static final Logger LOGGER = LoggerFactory.getLogger(GroupSmsTask.class);
	@ServiceSetter
	private SmsSenderService smsSenderService;

	@Override
	public void processTask(GroupSmsArgs args) {
		LOGGER.info("GroupSmsTask.processTask...... args :{}", args.toJsonObject());
		try {
			smsSenderService.sendSms(args.getSrcMobileNo(), args.getDestMobileNo(), args.getText(), args.getAppId());
		} catch (Exception ex) {
			LOGGER.error("invoke ISmsUniformMessage.SendSms occur error : {}", ex);
		}
	}
}
